package com.dr.springboot.starter.controller;

import com.dr.springboot.starter.entity.Resource;
import com.dr.springboot.starter.entity.ResourceYml;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ResourceController {

    @Autowired
    private Resource resource;

    @Autowired
    private ResourceYml resourceYml;

    @Value("${dr.name}")
    private String name;

    @GetMapping("/resource")
    public Resource getResource() {
        Resource resourceCopy=new Resource();
        BeanUtils.copyProperties(resource,resourceCopy);
        return resourceCopy;
    }

    @GetMapping("/yml_res")
    public ResourceYml getResourceYml() {
        ResourceYml resourceCopy=new ResourceYml();
        BeanUtils.copyProperties(resourceYml,resourceCopy);
        return resourceCopy;
    }

    @GetMapping("/string_res")
    public String getString() {
        return name;
    }
}
